<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>系统登录</title>
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
    <link rel="stylesheet" th:href="@{/css/AdminLTE.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/skin-red-light.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/animate.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/beyond.min.css}"/>
    <style>
        .login-bg {
            background-image: url("/img/bg.jpg");
            background-position: center center;
            background-repeat: no-repeat;
            background-size: cover;
        }
    </style>
</head>
<body class="login-bg">
<div class="login-container animated fadeInDown" style="width: 100%;height: 100%">
    <div class="loginbox bg-white" style="height: 260px!important;">
        <div class="loginbox-title" style="padding-top: 20px;margin-bottom: 20px">登陆</div>
        <form id="loginForm" action="/admin/login" method="post">
            <div class="loginbox-textbox">
                <input id="username" name="username" type="text" class="form-control" placeholder="管理账号">
            </div>
            <div class="loginbox-textbox">
                <input id="userpass" name="userpass" type="password" class="form-control" placeholder="密码">
            </div>
            <!--<div class="loginbox-textbox">-->
            <!--<input id="verify" type="text" name="verify" class="form-control" placeholder="验证码">-->
            <!--</div>-->
            <!--<div class="loginbox-textbox">-->
            <!--<img src="/wfx/Admin/Public/verify" width="100%" id="verifyimg">-->
            <!--</div>-->
            <div class="loginbox-forgot">
                <a href="javascript:alert('请联系管理员')">忘记密码?</a>
            </div>
            <div class="loginbox-submit">
                <input class="btn btn-primary btn-block" value="登陆" onclick="login()" type="button">
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/js/toastr/toastr.js}"></script>
<script type="text/javascript" th:src="@{/js/app.min.js}"></script>
<script type="text/javascript">
    var reg = /^\s*$/g; //匹配任意空白符

    function login() {
        var username = $('#username').val();
        var password = $('#userpass').val();
        if (reg.test(username)) {
            toastr.error("手机号不能为空");
            return;
        }
        if (reg.test(password)) {
            toastr.error("密码不能为空");
            return false;
        }
        $.ajax({
            url: "/admins/login",
            type: "post",
            dataType: "json",
            data: {
                "username": username,
                "password": password,
                "isRemember": 1
            },
            success: function (data) {
                if (data.code == 200) {
                    location.href = "/";
                } else {
                    toastr.error(data.msg);
                }
            },
            error: function (xhr, status, error) {
                var err = eval("(" + xhr.responseText + ")");
                toastr.error(err.msg);
            }
        });
    }

</script>
</body>
</html>